Skip to content

feat: NS 4.0 Integration #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 29, 2018
Merged

feat: NS 4.0 Integration #1250

merged 17 commits into from
Mar 29, 2018

Conversation

vakrilov
Copy link
Contributor

@vakrilov vakrilov commented Mar 22, 2018

Bootstrap and Navigation

NativeScript 4.0 allows you to put any view as the root(not only Frame) of the application. To support in angular projects we had to introduce some changes in how A{N}gular apps are bootstrapped.

Previous Behavior

Bootstrap creates a root Frame and initial Page. Then it bootstraps the angular application inside this page. Navigation with <page-router-outlet> will always navigate in the Frame created by the bootstrap.

Limitations:

  • You cannot change the root view of the app (to RadSideDrawer for example). It is always the Frame created by the bootstrap.
  • You can have only one <page-router-outlet> as there is only one Frame.
  • You always have a Page view wrapping your components and you can always. Because the ActionBar is part of that Page you can always change it with the <ActionBar> component.

New Behavior

Bootstrap will not create root view by default. It will use the root view of your main application component as the root view of the application. The <page-router-outlet> component will create its own Frame and will use it for navigation. It will also wrap the components you navigate to in a Page and will navigate to it as it did before.

Which means:

  • You can use any view for application root. Finally, you can have application-wide RadSideDrawer.

  • You have more flexibility over where to place the <page-router-outlet>, you can even have more than one for more advanced scenarios.

  • If you don't use <page-router-outlet> in your app you will not get the default Page and Frame, which means you will not be able to inject them in you components or show the ActionBar. There is special createFrameOnBootstrap option you can pass on bootstrap to make things as before:

platformNativeScript({ createFrameOnBootstrap: true })
    .bootstrapModuleFactory(AppModuleNgFactory);
  • If you are using <page-router-outlet> you probably don't have to do any changes. Bootstrap will not create Frame and Page, but the outlet will do that. It will also take care of providing Page and so the ActionBar should work as before.

Working with Frames

There might be multiple frames (if you have multiple <page-router-outlet>'s). Angular DI works with singletons, so it will always return one instance of Frame. We have introduced FrameService (still experimental) which has a getFrame() method. It will return the current frame (the one you have navigated last).

@ghost ghost assigned vakrilov Mar 22, 2018
@ghost ghost added the in progress label Mar 22, 2018
@vakrilov vakrilov force-pushed the ns-40-first-phase branch from f5f6543 to 20f6a90 Compare March 23, 2018 09:41
@ghost ghost assigned SvetoslavTsenov Mar 25, 2018
@SvetoslavTsenov
Copy link
Contributor

test

vakrilov and others added 14 commits March 25, 2018 16:27
Angular application is started with `application.run()` which means the the root view of the app will be the root view of the `AppComponent`.
Previous behavior: Anagular application was started with `application.start()` - this aways creates a root `Frame`. The platfrom bootstrap was always creating the inital `Page` and loading the `AppComponent` inside.

The `<page-router-outlet>` will create a Frame as a native element and will create a page for each component activated in it (including the inital page).
Add `tsc-w` script to plugin's `package.json` file.
Rename RootView class to AppHostView class.
Expose ngAppRoot property of AppHostView class.
Add modal-nested-test example.
@SvetoslavTsenov
Copy link
Contributor

test

@vakrilov vakrilov force-pushed the ns-40-first-phase branch from cca244f to 1d7237a Compare March 28, 2018 14:13
@vakrilov
Copy link
Contributor Author

test

@SvetoslavTsenov
Copy link
Contributor

test

2 similar comments
@SvetoslavTsenov
Copy link
Contributor

test

@SvetoslavTsenov
Copy link
Contributor

test

@vakrilov vakrilov changed the title [Do not merge]feat: NS 4.0 Integration feat: NS 4.0 Integration Mar 29, 2018
@vakrilov vakrilov merged commit 7bfddbb into master Mar 29, 2018
@ghost ghost removed the in progress label Mar 29, 2018
@vakrilov vakrilov deleted the ns-40-first-phase branch March 29, 2018 10:41
vakrilov pushed a commit that referenced this pull request Mar 29, 2018
feat: NS 4.0 Integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants